package newtest;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.apache.http.ssl.SSLContextBuilder;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import javax.net.ssl.SSLContext;
import java.io.*;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.*;

public class InsurerTaskV2 extends Thread{
	private int mIndex;
	public InsurerTaskV2(int index)
	{
		mIndex = index;
	}
	static String httpProtocol = "http";//http协议	
	static String username = "13312344321@163.COM";//对接人员账号
	static String password = "7a9e307df1cb7ae2a503897dbbfcc6f8";//对接人员密码
	static String ip = "127.0.0.1";
	static int port = 8081;
	static HttpHost target = null;
	
	public static void main(String[] args) throws Exception {
		
		for(int i = 0;i < 1;i++) {
			InsurerTaskV2 mTask = new InsurerTaskV2(i);
			mTask.start();
		}
	}
	
	public void run(){
		for(int i = 0; i < 1;i++) {
			try {
				String mStr = String.format("InsurerTask[%d],current index [%d]", mIndex,i);
				System.out.println(mStr);
				UploadTask("D:\\sl_video\\1588147326633.mp4");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	static CloseableHttpClient httpclient = null;
	private static void UploadTask(String fileName) throws Exception {
		File file = new File(fileName);
		if (!file.exists())
			throw new Exception("文件不存在");
		CloseableHttpClient httpclient = createSSLClientDefault();		
		try {
			HttpClientContext localContext = HttpClientContext.create();
			HttpPost httpPost = new HttpPost(httpProtocol + "://" + ip + ":" + port + "/insurer_task_v2");
			Task task = new Task();
			task.setTaskSource(2);
//			task.setTaskSource(1);
			task.setCounterid("123456");//销售人员工号 
			task.setCounterName("23343");//销售人员姓名
			task.setCounterPhone("18913100546");//销售人员电话
			task.setBankCode("100101");//销售人员所属机构编码  //正确 20171208
			task.setSubBankCode("100101018");//销售人员所属机构分行编码
//			task.setNodeBankCode("110000");//销售人员所属机构网点编码
			task.setSubInsurerCode("100101018");//保险公司代码（省级分公司）
			task.setProduct_code("TSU-0132");//产品代码
			task.setProduct_name("江苏-分红-健康险");//产品名称
			task.setBusinessType("1");//业务识别号类型
			Random random = new Random();
			task.setBusinessNo(""+ random.nextInt(100000) + random.nextInt(100000) + random.nextInt(100000)+ random.nextInt(100000) + random.nextInt(100000));//业务识别号【不需要填，系统自动生成】
//			task.setBranchUnitCode("201712080101");//保险公司支公司代码(市级分公司)
			task.setTaskType("100");//业务类型
			task.setInsuranceperiod("1");//保障期限
			task.setPayment_year(10);//缴费年限
			task.setPremium(100.00);//保费
			task.setCustomerName("张三");//客户姓名
			task.setCustomerCardType(111);//客户证件类型
			task.setCustomerCardNo("231181199809067788");//客户证件号码
			task.setCustomerBirthday("2012-01-02");//客户出生日期
			task.setVideoName("视频长度测试");//视频文件名【不需要填，系统自动生成】
			task.setVideoType(fileName.substring(fileName.lastIndexOf(".")+1));//视频格式类型【不需要填，系统自动生成】
			task.setBusinessSerialNo("0024");//业务流水号
			task.setBatchNo("2018052724");//批次号
			task.setContent_MD5(DigestUtils.md5Hex(new FileInputStream(file)));//文件签名【不需要填，系统自动生成】
			task.setPayment_term(3);//交费方式
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			task.setRecord_time(df.format(System.currentTimeMillis() - 60000 * 10));//录制时间
			task.setFile_time(1800);//录制时长
			task.setFile_length(file.length() / 1024);//文件长度【不需要填，系统自动生成】
			task.setBusiType("1");
			
			//以下为自定义参数的处理
			List<TaskImportParamVo> taskParamsList = new ArrayList<TaskImportParamVo>();//任务自定义参数，实际使用时应为/join/insurerParamsList?busiType=xx接口的返回值，示例代码手动创建一些测试数据
			List<TaskImportParamVo> policyParamsList = new ArrayList<TaskImportParamVo>();//保单自定义参数，实际使用时应为/join/insurerParamsList?busiType=xx接口的返回值，示例代码手动创建一些测试数据
			//以下是示例代码写的自定义参数传参，仅供参考！ 实际使用时，应以各保险公司实际的自定义参数为准-----start
			TaskImportParamVo taskParam1 = new TaskImportParamVo();
			//任务自定义参数1
			taskParam1.setParamCode("任务自定义参数1的参数标识");
			taskParam1.setParamName("任务自定义参数1的参数名称");
			taskParam1.setValue("任务自定义参数1的实际参数值");
			taskParamsList.add(taskParam1);
			//任务自定义参数2
			TaskImportParamVo taskParam2 = new TaskImportParamVo();
			taskParam2.setParamCode("任务自定义参数2的参数标识");
			taskParam2.setParamName("任务自定义参数2的参数名称");
			taskParam2.setValue("任务自定义参数2的实际参数值");
			taskParamsList.add(taskParam2);
			//任务自定义参数3
			TaskImportParamVo taskParam3 = new TaskImportParamVo();
			taskParam3.setParamCode("任务自定义参数2的参数标识");
			taskParam3.setParamName("任务自定义参数2的参数名称");
			taskParam3.setValue("任务自定义参数2的实际参数值");
			taskParamsList.add(taskParam3);
			//保单自定义参数1
			TaskImportParamVo policyParam1 = new TaskImportParamVo();
			policyParam1.setParamCode("保单自定义参数1的参数标识");
			policyParam1.setParamName("保单自定义参数1的参数名称");
			policyParam1.setValue("保单自定义参数1的实际参数值");
			policyParamsList.add(policyParam1);
			//保单自定义参数2
			TaskImportParamVo policyParam2 = new TaskImportParamVo();
			policyParam2.setParamCode("保单自定义参数2的参数标识");
			policyParam2.setParamName("保单自定义参数2的参数名称");
			policyParam2.setValue("保单自定义参数2的实际参数值");
			policyParamsList.add(policyParam2);
			//以上是示例代码写的自定义参数传参，仅供参考！ 实际使用时，应以各保险公司实际的自定义参数为准-----end
			//自定义参数以及赋值的传值，taskParamsList里每个对象最少需要包含paramCode、value这两个参数(如果该参数的配置，该项不是必填项，value值可以为空);
			task.setTaskParams(taskParamsList);
			task.setPolicyParams(policyParamsList);//如果保险公司未定义过自定义参数，这两个参数(taskParamsList、policyParamsList)可以不传、或者传空集合
			String body = JSON.toJSONString(task);
			System.out.println(body);
			httpPost.setHeader("Content-Type", "application/json");
			StringEntity stringEntity = new StringEntity(body, "UTF-8");// 解决中文乱码问题
			stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=utf8"));
			httpPost.setEntity(stringEntity);
			CloseableHttpResponse response = httpclient.execute(target, httpPost, localContext);
			try {
				System.out.println("------------------UpdateTask----------------------");
				StatusLine tLine = response.getStatusLine();
				System.out.println(tLine);
				HttpEntity entity = response.getEntity();
				String data = IOUtils.toString(entity.getContent(), "UTF-8");
				System.out.println(data);
				if (tLine.getStatusCode() == 200) {
					JSONObject taskObject = JSON.parseObject(data);
					String etag = fileUpload(fileName, taskObject.getString("bucket"), taskObject.getString("object"));
					// String etag = fileUpload("D:\partVideo.rar", taskObject.getString("bucket"),
					// taskObject.getString("object"));
					System.out.println("------------------上传完成etag" + etag + "----------------------");
					if (!etag.isEmpty()) {
						UpdateTastStatus(etag, taskObject.getString("task_id"));// 更新任务状态
					}
				}
			} finally {
				response.close();
			}
		} finally {
//			httpclient.close();
		}
	}

	/**
	 * 获取授权
	 * 
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	private static Map<String, String> GetInsurerGetauthor(JSONObject jsonObject)
			throws ClientProtocolException, IOException {
		CloseableHttpClient httpclient = createSSLClientDefault();
		try {
			HttpClientContext localContext = HttpClientContext.create();
			HttpPut httpPut = new HttpPut(httpProtocol + "://" + ip + ":" + port + "/insurer_getauthor");

			String body = jsonObject.toJSONString();
			httpPut.setHeader("Content-Type", "application/json");
			StringEntity stringEntity = new StringEntity(body, "UTF-8");// 解决中文乱码问题
			stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=utf8"));
			httpPut.setEntity(stringEntity);
			CloseableHttpResponse response = httpclient.execute(target, httpPut, localContext);
			try {
				System.out.println("------------------GetInsurerGetauthor----------------------");
				StatusLine tLine = response.getStatusLine();
				System.out.println(tLine);
				HttpEntity entity = response.getEntity();
				String data = IOUtils.toString(entity.getContent(), "UTF-8");
				System.out.println(data);
				if (tLine.getStatusCode() == 200) {
					JSONObject tmpObject = JSON.parseObject(data);
					Map<String, String> tmpMap = new HashMap<String, String>();
					tmpMap.put("url", tmpObject.getString("url"));
					tmpMap.put("method", tmpObject.getString("method"));
					tmpMap.put("host", tmpObject.getString("host"));
					return tmpMap;
				}
				return null;
			} finally {
				response.close();
			}
		} finally {
			//httpclient.close();
		}
	}

	/**
	 * 上传视频
	 * 
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private static String UploadVideo(Map<String, String> tmpMap, File file)
			throws ClientProtocolException, IOException {
		CloseableHttpClient httpclient = createSSLClientDefault();
		HttpPut httpPut = new HttpPut(tmpMap.get("url"));
		httpPut.setHeader("Host", tmpMap.get("host"));
		FileInputStream fInputStream = new FileInputStream(file);
		InputStreamEntity inputStreamEntity = new InputStreamEntity(fInputStream);
		httpPut.setEntity(inputStreamEntity);
		CloseableHttpResponse response = httpclient.execute(httpPut);
		try {
			System.out.println("-------------------UploadVideo---------------------");
			StatusLine tLine = response.getStatusLine();
			System.out.println(tLine);
			System.out.println(response.getFirstHeader("ETag").getValue());
			if (tLine.getStatusCode() == 200) {
				String etag = response.getFirstHeader("ETag").getValue();
				return etag;
			} else {
				return "";
			}
		} finally {
			response.close();
		}
	}

	/**
	 * 获取受信任httpClient
	 * 
	 * @return
	 */
	public static CloseableHttpClient createSSLClientDefault() {
		if (target == null)
			target = new HttpHost(ip, port, httpProtocol);

		CloseableHttpClient httpClient = null;
		CredentialsProvider credsProvider = new BasicCredentialsProvider();
		credsProvider.setCredentials(new AuthScope(target.getHostName(), target.getPort()),
				new UsernamePasswordCredentials(username, DigestUtils.md5Hex(password)));
		SSLContext sslContext;

		try {
			sslContext = new SSLContextBuilder().loadTrustMaterial(null, (certificate, authType) -> true).build();
			SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new String[] { "TLSv1.2" },
					null, new NoopHostnameVerifier());
			httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).setDefaultCredentialsProvider(credsProvider)
					.build();
			return httpClient;
		} catch (KeyManagementException e) {
			e.printStackTrace();
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (KeyStoreException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 更新任务状态
	 * 
	 * @param etag
	 * @param taskId
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private static boolean UpdateTastStatus(String etag, String taskId) throws ClientProtocolException, IOException {
		CloseableHttpClient httpclient = createSSLClientDefault();
		try {
			String enUrl = httpProtocol + "://" + ip + ":" + port + "/insurer_update_task?task_id=" + taskId + "&ETag="
					+ URLEncoder.encode(etag, "UTF-8");
			HttpPost httpPost = new HttpPost(enUrl);

			CloseableHttpResponse response = httpclient.execute(target, httpPost);
			try {
				System.out.println("-------------------UpdateTastStatus---------------------");
				StatusLine tLine = response.getStatusLine();
				System.out.println(tLine);
				HttpEntity entity = response.getEntity();
				String data = IOUtils.toString(entity.getContent(), "UTF-8");
				System.out.println(data);
				if (tLine.getStatusCode() == 200)
					return true;
				else {
					return false;
				}
			} finally {
				response.close();
			}
		} finally {
			//httpclient.close();
		}
	}

	/**
	 * 文件上传
	 * 
	 * @param fileName
	 *            文件名
	 * @param bucket
	 *            桶名称
	 * @param object
	 *            对象名称
	 * @return etag
	 * @throws Exception
	 */
	private static String fileUpload(String fileName, String bucket, String object) throws Exception {
		File tmpFile = new File(fileName);
		FileInputStream tmpStream = new FileInputStream(tmpFile);
		long fileLength = tmpFile.length();
		String uploadId = "";
		int fileSize = 5 * 1024 * 1024;
		if (fileLength > fileSize) {// 分段上传
			JSONObject taskObject = new JSONObject();
			taskObject.put("bucket", bucket);
			taskObject.put("object", object);
			taskObject.put("method", "POST");
			taskObject.put("subresource", "uploads");
			Map<String, String> tmpMap = GetInsurerGetauthor(taskObject);// 获取分段上传初始化授权
			uploadId = InitPartUploade(tmpMap);
			long tmpValue = fileLength % fileSize;
			if (tmpValue != 0)
				tmpValue = fileLength / fileSize + 1;
			else {
				tmpValue = fileLength / fileSize;
			}
			Map<Integer, String> fileTags = new HashMap<Integer, String>();
			for (int i = 1; i <= tmpValue; i++) {
				try {
					fileSize = (int) Math.min(fileSize, (fileLength - fileSize * (i - 1)));
					taskObject = new JSONObject();
					taskObject.put("bucket", bucket);
					taskObject.put("object", object);
					taskObject.put("method", "PUT");
					JSONObject subObject = new JSONObject();
					subObject.put("uploadId", uploadId);
					subObject.put("partNumber", i);
					taskObject.put("parameters", subObject);
					tmpMap = GetInsurerGetauthor(taskObject);// 获取分段上传授权
					byte[] tmpBytes = new byte[fileSize];
					tmpStream.read(tmpBytes);
					String etag = PartUpload(tmpMap, tmpBytes);
					if (etag.isEmpty())
						return "上传终止";
					fileTags.put(i, etag);
				} catch (Exception ex) {
					System.out.println(ex.getMessage());
				}
			}
			tmpStream.close();

			taskObject = new JSONObject();
			taskObject.put("bucket", bucket);
			taskObject.put("object", object);
			taskObject.put("method", "POST");
			JSONObject subObject = new JSONObject();
			subObject.put("uploadId", uploadId);
			taskObject.put("parameters", subObject);
			// 上传完成
			tmpMap = GetInsurerGetauthor(taskObject);// 获取合并分段授权
			return CompleteUpload(tmpMap, fileTags);
		} else {// 单个上传
			JSONObject taskObject = new JSONObject();
			taskObject.put("bucket", bucket);
			taskObject.put("object", object);
			taskObject.put("method", "PUT");
			Map<String, String> tmpMap = GetInsurerGetauthor(taskObject);// 获取授权
			return UploadVideo(tmpMap, tmpFile);
		}
	}

	public static byte[] getBytes(String filePath) {
		byte[] buffer = null;
		try {
			File file = new File(filePath);
			FileInputStream fis = new FileInputStream(file);
			ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
			byte[] b = new byte[1000];
			int n;
			while ((n = fis.read(b)) != -1) {
				bos.write(b, 0, n);
			}
			fis.close();
			bos.close();
			buffer = bos.toByteArray();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return buffer;
	}

	/**
	 * 分段上传初始化
	 * 
	 * @param tmpMap
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private static String InitPartUploade(Map<String, String> tmpMap) throws ClientProtocolException, IOException {
		CloseableHttpClient httpclient = createSSLClientDefault();
		HttpPost httpPost = new HttpPost(tmpMap.get("url"));
		httpPost.setHeader("Host", tmpMap.get("host"));
		CloseableHttpResponse response = httpclient.execute(httpPost);
		try {
			System.out.println("-------------------InitPartUploade---------------------");
			StatusLine tLine = response.getStatusLine();
			System.out.println(tLine);
			if (tLine.getStatusCode() == 200) {
				HttpEntity entity = response.getEntity();
				String data = IOUtils.toString(entity.getContent(), "UTF-8");
				Document document;
				try {
					document = DocumentHelper.parseText(data);
				} catch (DocumentException e) {
					return "";
				}
				Element element = document.getRootElement();
				if (element != null) {
					Element eUploadId = element.element("UploadId");
					String uploadId = eUploadId.getStringValue();
					return uploadId;
				}
				return "";
			} else {
				return "";
			}
		} finally {
			response.close();
		}
	}

	static CloseableHttpClient httpclientUpload = null;

	/**
	 * 分段上传视频
	 * 
	 * @param tmpMap
	 * @param tmpBytes
	 *            输入字节
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private static String PartUpload(Map<String, String> tmpMap, byte[] tmpBytes)
			throws ClientProtocolException, IOException {
		try {
			InputStreamEntity inputStreamEntity = new InputStreamEntity(new ByteArrayInputStream(tmpBytes));
			httpclientUpload = createSSLClientDefault();
			HttpPut httpPut = new HttpPut(tmpMap.get("url"));
			httpPut.setHeader("Host", tmpMap.get("host"));
			httpPut.setEntity(inputStreamEntity);
			CloseableHttpResponse response = httpclientUpload.execute(httpPut);
			System.out.println("-------------------PartUpload---------------------");
			StatusLine tLine = response.getStatusLine();
			System.out.println(tLine);
			System.out.println(response.getFirstHeader("ETag").getValue());
			if (tLine.getStatusCode() == 200) {
				String etag = response.getFirstHeader("ETag").getValue();
				return etag;
			} else {
				return "";
			}
		} catch (Exception e) {
			return PartUpload(tmpMap, tmpBytes);
		}
	}

	String testMethod(CloseableHttpClient httpclient) throws IOException {
		try {
			Thread.sleep(1000);
			httpclient.close();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("call testMethod method.");
		return "test";
	}

	/**
	 * 完成分段上传视频
	 * 
	 * @param tmpMap
	 * @param fileTags
	 *            上传的分片集合
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private static String CompleteUpload(Map<String, String> tmpMap, Map<Integer, String> fileTags)
			throws ClientProtocolException, IOException {
		CloseableHttpClient httpclient = createSSLClientDefault();
		HttpPost httpPost = new HttpPost(tmpMap.get("url"));
		httpPost.setHeader("Host", tmpMap.get("host"));

		Document document = DocumentHelper.createDocument();
		Element root = DocumentHelper.createElement("CompleteMultipartUpload");
		document.setRootElement(root);
		for (int i = 1; i <= fileTags.size(); i++) {
			Element partElement = root.addElement("Part");
			Element partNumElement = partElement.addElement("PartNumber");
			partNumElement.addText(String.valueOf(i));
			Element etagElement = partElement.addElement("ETag");
			etagElement.addText(fileTags.get(i));
		}
		StringEntity sEntity = new StringEntity(document.asXML());
		httpPost.setEntity(sEntity);

		CloseableHttpResponse response = httpclient.execute(httpPost);
		try {
			System.out.println("-------------------CompleteUpload---------------------");
			StatusLine tLine = response.getStatusLine();
			System.out.println("-------------------" + tLine.toString() + "---------------------");
			if (tLine.getStatusCode() == 200) {
				String data = IOUtils.toString(response.getEntity().getContent(), "UTF-8");
				try {
					document = DocumentHelper.parseText(data);
				} catch (DocumentException e) {
					return "";
				}
				Element element = document.getRootElement();
				if (element != null) {
					Element etagEle = element.element("ETag");
					String etag = etagEle.getStringValue();
					return etag;
				}
				return "";
			} else {
				return "";
			}
		} finally {
			response.close();
		}
	}
	
	/**
	 * @param type
	 *            1-任务参数   2-保单参数
	 *            
	 * 手动模拟一些任务、保单的自定义参数
	 * 实际使用时应使用 /join/insurerParamsList?busiType=xx 接口的返回值作为对应的任务、保单的自定义参数
	 * 
	 * @return
	 */
	private List<TaskImportParamVo> createTaskParamsDataForDemo(int type){
		List<TaskImportParamVo> taskParams = new ArrayList<TaskImportParamVo>();
		List<TaskImportParamVo> policyParams = new ArrayList<TaskImportParamVo>();
		TaskImportParamVo taskParam = new TaskImportParamVo();
		if(type == 1){
			JSONObject object = JSONObject.parseObject("{\"taskParams\":[{\"busiTypeValue\":\"1\",\"paramCode\":\"G1\",\"paramName\":\"字符+文本\",\"paramType\":1,\"dataType\":1,\"ctrlType\":1,\"precision\":null,\"dataSourceType\":null,\"dataSource\":null,\"required\":1,\"minValue\":null,\"maxValue\":null,\"maxLength\":5,\"regexExpression\":\"\",\"value\":null},{\"busiTypeValue\":\"1\",\"paramCode\":\"G2\",\"paramName\":\"字符+下拉\",\"paramType\":1,\"dataType\":1,\"ctrlType\":2,\"precision\":null,\"dataSourceType\":2,\"dataSource\":\"[{\"name\":\"1\",\"value\":\"1\"},{\"name\":\"2\",\"value\":\"2\"},{\"name\":\"3\",\"value\":\"3\"},{\"name\":\"4\",\"value\":\"4\"},{\"name\":\"5\",\"value\":\"5\"},{\"name\":\"6\",\"value\":\"6\"},{\"name\":\"7\",\"value\":\"7\"},{\"name\":\"8\",\"value\":\"8\"},{\"name\":\"9\",\"value\":\"9\"},{\"name\":\"10\",\"value\":\"10\"},{\"name\":\"11\",\"value\":\"11\"},{\"name\":\"12\",\"value\":\"12\"},{\"name\":\"13\",\"value\":\"13\"},{\"name\":\"14\",\"value\":\"14\"},{\"name\":\"15\",\"value\":\"15\"},{\"name\":\"16\",\"value\":\"16\"}]\",\"required\":1,\"minValue\":null,\"maxValue\":null,\"maxLength\":null,\"regexExpression\":\"\",\"value\":null},{\"busiTypeValue\":\"1\",\"paramCode\":\"G3\",\"paramName\":\"字符+日期\",\"paramType\":1,\"dataType\":1,\"ctrlType\":3,\"precision\":null,\"dataSourceType\":null,\"dataSource\":null,\"required\":0,\"minValue\":null,\"maxValue\":null,\"maxLength\":null,\"regexExpression\":\"\",\"value\":null},{\"busiTypeValue\":\"1\",\"paramCode\":\"G4\",\"paramName\":\"数值+文本（输入10-200之间的数值）43214213412342134213\",\"paramType\":1,\"dataType\":2,\"ctrlType\":1,\"precision\":1,\"dataSourceType\":null,\"dataSource\":null,\"required\":1,\"minValue\":10.00,\"maxValue\":200.00,\"maxLength\":5,\"regexExpression\":\"\",\"value\":null},{\"busiTypeValue\":\"1\",\"paramCode\":\"G5\",\"paramName\":\"日期+日期\",\"paramType\":1,\"dataType\":3,\"ctrlType\":3,\"precision\":null,\"dataSourceType\":null,\"dataSource\":null,\"required\":0,\"minValue\":null,\"maxValue\":null,\"maxLength\":null,\"regexExpression\":\"\",\"value\":null}],\"policyParams\":[{\"busiTypeValue\":\"1\",\"paramCode\":\"YWYXM\",\"paramName\":\"业务员姓名\",\"paramType\":2,\"dataType\":1,\"ctrlType\":9,\"precision\":null,\"dataSourceType\":null,\"dataSource\":null,\"required\":0,\"minValue\":null,\"maxValue\":null,\"maxLength\":null,\"regexExpression\":null,\"value\":null},{\"busiTypeValue\":\"1\",\"paramCode\":\"GSMC\",\"paramName\":\"公司名称\",\"paramType\":2,\"dataType\":1,\"ctrlType\":9,\"precision\":null,\"dataSourceType\":null,\"dataSource\":null,\"required\":0,\"minValue\":null,\"maxValue\":null,\"maxLength\":null,\"regexExpression\":null,\"value\":null},{\"busiTypeValue\":\"1\",\"paramCode\":\"MQBF\",\"paramName\":\"每期保费\",\"paramType\":2,\"dataType\":2,\"ctrlType\":9,\"precision\":2,\"dataSourceType\":null,\"dataSource\":null,\"required\":0,\"minValue\":null,\"maxValue\":null,\"maxLength\":null,\"regexExpression\":null,\"value\":null},{\"busiTypeValue\":\"1\",\"paramCode\":\"BDBZQX\",\"paramName\":\"保单保障期限\",\"paramType\":2,\"dataType\":1,\"ctrlType\":2,\"precision\":null,\"dataSourceType\":1,\"dataSource\":\"[{\"dict_type\":\"insurance_period_type\",\"name\":\"一年期及以下\",\"value\":\"1\"},{\"dict_type\":\"insurance_period_type\",\"name\":\"一年期以上\",\"value\":\"2\"},{\"dict_type\":\"insurance_period_type\",\"name\":\"不限\",\"value\":\"3\"}]\",\"required\":1,\"minValue\":null,\"maxValue\":null,\"maxLength\":null,\"regexExpression\":null,\"value\":null},{\"busiTypeValue\":\"1\",\"paramCode\":\"0728002\",\"paramName\":\"参数2\",\"paramType\":2,\"dataType\":3,\"ctrlType\":3,\"precision\":null,\"dataSourceType\":null,\"dataSource\":null,\"required\":1,\"minValue\":null,\"maxValue\":null,\"maxLength\":null,\"regexExpression\":\"\",\"value\":null}]}");
			
			TaskImportParamVo vo = new TaskImportParamVo();
			vo.setBusiTypeValue("1");
			vo.setParamCode("");
			return taskParams;
		}
		if(type == 2){
			
			return policyParams;
		}
		return null;
	}
}
